package org.yagnus.langutils.mutables;

public final class MutableDouble {
    double v;

    public final double apply() {
        return v;
    }

    public final double get() {
        return v;
    }

    public final double inc() {
        return (v += 1);
    }

    public final double dec() {
        return (v -= 1);
    }

    public final double inc(double d) {
        return (v += d);
    }

    public final double dec(double d) {
        return (v -= d);
    }

    @Override
    public final String toString() {
        return "MutableDouble [v=" + v + "]";
    }

    @Override
    public final int hashCode() {
        final int prime = 31;
        int result = 1;
        long temp;
        temp = Double.doubleToLongBits(v);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    @Override
    public final boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        MutableDouble other = (MutableDouble) obj;
        if (v != other.v)
            return false;
        return true;
    }

    public MutableDouble(double v) {
        super();
        this.v = v;
    }

}
